﻿using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
using LuckyFish.Ledger.Data;

namespace LuckyFish.Ledger.App.Views;

public partial class AddCategoryView : Window
{
    public AddCategoryView()
    {
        InitializeComponent();
#if DEBUG
        this.AttachDevTools();
#endif
        CategoryNameBox = this.FindControl<TextBox>("CategoryNameBox");
        ExplanationBox = this.FindControl<TextBox>("ExplanationBox");
    }

    private void InitializeComponent()
    {
        AvaloniaXamlLoader.Load(this);
    }

    private void Ok(object? sender, RoutedEventArgs e)
    {
        Close(new CategoryModel(){CategoryName = CategoryNameBox.Text,Explanation = ExplanationBox.Text});
    }

    private void Cancel(object? sender, RoutedEventArgs e)
    {
        Close(default(CategoryModel));
    }
}